prepareQuery();
$table = $config->sql_tablename_pictures();
$picpath = $config->picture_storepath();
$fileshortcode = strtolower(trim($func->stripHtml($_REQUEST['s'])));
$startpage = strtolower(trim($func->stripHtml($_REQUEST['m'])));
$stmt = $pdo->prepare("SELECT p_filename,p_uri FROM $table WHERE p_shortcode=:shortcode LIMIT 1");
$stmt->bindValue(':shortcode', $fileshortcode, PDO::PARAM_STR);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$filename = trim($rows[0]["p_filename"]);
$source = trim($rows[0]["p_uri"]);
$fn = "$picpath/$filename";
$myfilemtime = filemtime($fn);
$headers = $func->request_headers();
// Checking if the client is validating his cache and if it is current.
if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == $myfilemtime)) {
// Client's cache IS current, so we just respond '304 Not Modified'.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $myfilemtime).' GMT', true, 304);
} else {
// Image not cached or cache outdated, we respond '200 OK' and output the image.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $myfilemtime).' GMT', true, 200);
//header('Content-Length: '.filesize($fn));
}
$imageRetArray = $func->getScreenResolutionFromUA($startpage);
$x = $imageRetArray["x"];
$y = $imageRetArray["y"];
$fontsize = $imageRetArray["fontsize"];
$picQuality = $imageRetArray["picQuality"];
/*
//$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
//echo "deviceType=$deviceType";
$deviceTypeMobile = $detect->isMobile();
$deviceTypeTablet = $detect->isTablet();
//320x240, 480x320, 800x480, 960x480, 1024x800, and 1024x768
$picQuality = 75;
if (strpos($startpage, '1') !== FALSE){
$x = 320;
$y = 265;
$fontsize = 9;
$picQuality = 78;
} elseif (strpos($startpage, '2') !== FALSE){
$x = 60;
$y = 75;
$fontsize = 7;
$picQuality = 73;
} elseif ($deviceTypeTablet === TRUE){
// we have a tablet device
$x = 640;
$y = 380;
$fontsize = 12;
$picQuality = 85;
} elseif ($deviceTypeMobile === TRUE){
// we have a mobile device
$x = 480;
$y = 320;
$fontsize = 10;
$picQuality = 71;
} else {
// we have a desktop device
$x = 960;
$y = 680;
$fontsize = 15;
$picQuality = 95;
}*/
if (!empty($filename)&&strlen($filename)>3&&file_exists("$picpath/$filename")){
$source = str_ireplace("http://","",$source);
$textinfo = "Quelle: $source";
//if ($service->isValidBot() == 1 ){
// $textinfo = "Mehr coole News gibts auf BuzzerStar.com";
//}
$textinfo = "Coole News gibts auf BuzzerStar.com";
try {
$img = new SimpleImage();
$img->load("$picpath/$filename");
$img->text($textinfo,"./library/fonts/delicious.ttf", $fontsize, '#000000', 'bottom left', 0, -10);
// $img->resize($x, $y);
// $img->adaptive_resize($x, $y);
$img->best_fit($x, $y);
/*
//$ext = pathinfo($filename, PATHINFO_EXTENSION);
if ($imgSrc->checkExtension($filename) == 1){
$extension = $imgSrc->getExtension($filename);
$img->output($extension);
} else {
$img->output('jpg');
}
*/
$img->output('jpg',$picQuality);
$stmt = null; // doing this is mandatory for connection to get closed
$pdo = null;
exit(0);
} catch(Exception $e) {
// echo '' . $e->getMessage() . '';
}
} else {
$source = "http://www.solidcam.de/spezielle-seiten/fehler-404-seiten-nicht-gefunden/";
$source = str_ireplace("http://","",$source);
try {
$img = new SimpleImage();
$img->load("/home/wwwbuzzerstar/images/filenotfound.png");
$img->text("Quelle: $source","./library/fonts/delicious.ttf", $fontsize, '#000000', 'bottom left', 0, -10);
$img->best_fit($x, $y);
//$img->resize($x, $y);
$img->output('jpg',$picQuality);
} catch(Exception $e) {
// echo '' . $e->getMessage() . '';
}
}
$stmt = null; // doing this is mandatory for connection to get closed
$pdo = null;
exit(0);
?>